package com.miniprogram.bean.po;

<#list table.importPackages as pkg>
import ${pkg};
</#list>
import io.swagger.annotations.ApiModel;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * <p>
 * ${table.comment!}
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("${table.name}")
@ApiModel(value="${entity}对象", description="${table.comment!}")
public class ${entity} extends ${superEntityClass} implements Serializable {

    <#-- ----------  BEGIN 字段循环遍历  ---------->
    <#list table.fields as field>
    <#if field.name!='create_user' && field.name!='create_time' && field.name!='update_user' && field.name!='update_time' && field.name!='deleted'>
    <#if field.keyFlag>
    <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
    <#if field.comment!?length gt 0>
    <#if swagger2>
    @ApiModelProperty(value="${field.comment}")
    <#else>
    /**
     * ${field.comment}
     */
    </#if>
    </#if>
    <#if field.keyFlag>
    <#-- 主键 -->
    <#if field.keyIdentityFlag>
    @TableId(value = "${field.name}", type = IdType.AUTO)
    <#elseif idType??>
    @TableId(value = "${field.name}", type = IdType.${idType})
    <#elseif field.convert>
    @TableId("${field.name}")
    </#if>
    <#-- 普通字段 -->
    <#elseif field.fill??>
    <#-- -----   存在字段填充设置   ----->
    <#if field.convert>
    @TableField(value = "${field.name}", fill = FieldFill.${field.fill})
    <#else>
    @TableField(fill = FieldFill.${field.fill})
    </#if>
    <#elseif field.convert>
    @TableField("${field.name}")
    </#if>
    <#-- 乐观锁注解 -->
    <#if (versionFieldName!"") == field.name>
    @Version
    </#if>
    <#-- 逻辑删除注解 -->
    <#if (logicDeleteFieldName!"") == field.name>
    @TableLogic
    </#if>
    private ${field.propertyType} ${field.propertyName};

    </#if>
    </#list>
    <#------------  END 字段循环遍历  ---------->
    <#if !entityLombokModel>
    <#list table.fields as field>
    <#if field.propertyType == "boolean">
    <#assign getprefix="is"/>
    <#else>
    <#assign getprefix="get"/>
    </#if>
    public ${field.propertyType} ${getprefix}${field.capitalName}() {
    return ${field.propertyName};
}

    <#if entityBuilderModel>
    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
    <#else>
    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
    </#if>
    this.${field.propertyName} = ${field.propertyName};
    <#if entityBuilderModel>
    return this;
    </#if>
}
    </#list>
    </#if>

    <#if entityColumnConstant>
    <#list table.fields as field>
    public static final String ${field.name?upper_case} = "${field.name}";

    </#list>
    </#if>

    <#if !entityLombokModel>
    @Override
    public String toString() {
        return "${entity}{" +
        <#list table.fields as field>
        <#if field_index==0>
        "${field.propertyName}=" + ${field.propertyName} +
        <#else>
        ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
        </#list>
        "}";
    }
    </#if>
}
